<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>禁毒清源系统
    </title>
    <link href="/resources/css/css.css" rel="stylesheet" type="text/css"/>
    <script src="/resources/common/js/jquery-1.11.3.min.js"></script>
    <script src="/resources/js/self.js"></script>
    <script type="text/javascript" src="/resources/common/js/md5.js"></script>
    <style type="text/css">
        input::-webkit-input-placeholder {
            color: #fff;
        }

        input::-moz-placeholder { /* Mozilla Firefox 19+ */
            color: #fff;
        }

        input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
            color: #fff;
        }

        input:-ms-input-placeholder { /* Internet Explorer 10-11 */
            color: #fff;
        }
    </style>
</head>

<body>
<div class="zcbg" style="padding-top: 100px;background-size: cover;">
    <div class="zcmain">
        <div class="zctitle"><img src="/resources/images/dllogo.png"/></div>
        <div class="zcbody">
            <div class="zcxx">
                <ul>
                    <li><p>用户名</p>
                        <Span>  <input name="account" class="dlname" type="text"
                                       placeholder="请输入用户名"
                                       foundfield="" compareway="2">
		  </Span>
                    </li>

                    <li>
                        <p>密码</p><Span><input name="password" class="dlname" type="password" placeholder="输入您的密码"
                                              foundfield="" compareway="2"></Span>
                    </li>

                    <li><p>企业类型</p><Span>
		 <select id="userType" name="userType" class="yzmc">
      <option value="company">生产企业</option>
      <option value="trans">运输企业</option>
      <option value="buy">采购企业</option>
    </select>
		 </Span></li>


                </ul>


                <div class="clear"></div>
            </div>
            <button class="dlbut" onclick="login()">登录</button>
            <div class="clear"></div>
            <div class="dlqzc">如果您还没有账号请先去<a href="/html/zhuce.html">注册</a></div>
            <div class="clear"></div>
        </div>
    </div>
</div>
</body>
<script type="application/javascript">
    function login() {
        var userType = $("#userType").val();
        var account = $("input[name='account']").val();
        var password = $("input[name='password']").val();
        if (account.replace(/\s/g, '') == '') {
            alert("请输入登陆账号");
            return;
        }
        if (password.replace(/\s/g, '') == '') {
            alert("请输入密码");
            return;
        }
        var params = {};
        params['account'] = account;
        params['password'] = hex_md5(password);
        var url = getUrl(userType);
        $.ajax({
            url: url,
            type: 'post',
            data: params,
            success: function (data) {
                if (data.success) {
                    if (data.data.auditStatus == 'auditSuccess') {
                        window.location.href = getIndexUrl(userType);
                    } else {
                        window.location.href = getInitUrl(userType);
                    }

                } else {
                    alert(data.msg);
                }
            },
            error: function () {
                alert("系统错误！");
            }
        });
    }

    function getUrl(userTye) {
        var url = "";
        if (userTye == "company") {
            url = "/company/loginOn.do"
        } else if (userTye == "trans") {
            url = "/trans/loginOn.do"
        } else if (userTye == "buy") {
            url = "/buy/loginOn.do"
        }
        return url;
    }

    function getInitUrl(userTye) {
        var url = "/html/" + userTye + "/zhuce_1.html?r=" + new Date().getTime();
        return url;
    }

    function getIndexUrl(userTye) {
        var url = "/html/" + userTye + "/index.html?r=" + new Date().getTime();
        return url;
    }
</script>
</html>
